import java.io.IOException;

public class Main{

	/**
	 * @param args
	 * @throws IOException
	 * @throws NumberFormatException
	 */
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		java.io.BufferedReader r = new java.io.BufferedReader(
				new java.io.InputStreamReader(System.in));

		long[] cycle = { 192, 442, 692, 942 };

		long number = Long.parseLong((r.readLine()));
		for (int i = 0; i < number; i++) {
			long k = Long.parseLong((r.readLine()));
			System.out.println(((k - 1) / 4) * 1000
					+ cycle[(int) ((k - 1) % 4)]);
		}
	}
}
